package jp.co.ziro.wikidozan.controller.wiki;

import java.util.logging.Logger;

import jp.co.ziro.wikidozan.controller.BaseController;
import jp.co.ziro.wikidozan.controller.ControllerResponse;
import jp.co.ziro.wikidozan.controller.Request;
import jp.co.ziro.wikidozan.util.ShowWikiArticleView;
import jp.co.ziro.wikidozan.util.WikiArticle;



public class ShowController extends BaseController {

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(ShowController.class.getName());

    private static final String HOME_PAGE = "Main Page";

    @Override
    protected ControllerResponse createResponse(Request requestData)
            throws Exception {

        WikiArticle article = new WikiArticle(requestData.getPath().getId());
        ShowWikiArticleView view = new ShowWikiArticleView(article);
        if (article.getTitle().equals(HOME_PAGE)) {
           return requestData.xmlResponse(view.toXml(), "home");
        } else {
           return requestData.xmlResponse(view.toXml(),"show");
        }
    }

}
